define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	
	var Model = function(){
		this.callParent();
		this.type = "";
	};
	Model.prototype.getLeftImageUrl = function(url) {
		return url?this.getParentModel().serverUrl+url:require.toUrl("$UI/CommunityOto/category/img/loading.jpg");
	};
	
	Model.prototype.getImageUrl = function(row){
		return require.toUrl(row.val('imgSrc'));
	};
	

	
	Model.prototype.gonggaoBack = function(event){
		this.comp("windowReceiver1").windowEnsure();
		this.getParentModel().goBackHome();
		
		//console.log(this.getParent());
		
	};
	
	Model.prototype.notifyDataCustomRefresh = function(event){
	   
		var id;
	    var title;
	    if(this.type=="notify"){
	        var companyInfo = JSON.parse(localStorage.getItem("companyInfo"));
	    	id = companyInfo.id;
	    	title = "社区公告";
	    	this.comp("titleBar").set({title:title});
	    	var url = this.getParentModel().serverUrl + "/ex_community/a/api/community/getNotify?callback=?";	
	    	$.getJSON(
	    			url,
	    			{
	    				id:id
	    			},
	    			function(data){
					
	    				event.source.loadData(data.data);
					//console.log("data",event.source.getFirstRow());
					//console.log("data",event.source.getFirstRow());
				}
		);
	    }else{
	        var officeInfo = JSON.parse(localStorage.getItem("companyInfo"));
	        id = officeInfo.id;
	        title = "物业通知";
	        this.comp("titleBar").set({title:title});
	        var url = "http://www.xjzlhy.com:81/ex_community/a/api/community/getNotifyNew?callback=?";	
	        $.getJSON(
	        		url,
	        		{
//	        			id:id
	        		},
	        		function(data){
					
	        			event.source.loadData(data.data);
					//console.log("data",event.source.getFirstRow());
					//console.log("data",event.source.getFirstRow());
				}
		);
	    }
	    

	};
	
	Model.prototype.notifyItemClick = function(event){
		var row = event.bindingContext.$object;		
		var option = {
				type:this.type,
				title:row.val("title"),
				content:row.val("content")
		};
		
		justep.Shell.showPage("$UI/communityOto/community/channel/template.w",option);

	};
	
	
	
	Model.prototype.onTouchStart = function(event){
	
	     $(event.currentTarget).addClass("touch");

	};
	
	
	
	Model.prototype.onTouchEnd = function(event){
		$(event.currentTarget).removeClass("touch");
	};
	
	
	
	Model.prototype.modelParamsReceive = function(event){
	  
		this.type = this.getContext().getRequestParameter("type");		
		
		this.comp("notifyList").refresh(true);
	};
	
	
	
	return Model;
});